package tests;

import java.io.IOException;

import  mat.Mat;
import  types.MDoc;
import  types.MLabel;
import  types.MObject;
import  types.MPic;

public class testcase1 {
	public testcase1() throws IOException{
	//	Vector<MObject> objList = new Vector<MObject>();
		
		MDoc myMDoc = new MDoc(1280,800); //1
		myMDoc.type =  types.MType.DOCTYPE;
//		Mat.addNode(myMDoc);
	
		MLabel ad = new MLabel();  //2
		Mat.addNode(ad);
		
		MLabel[] title = new MLabel[2];
		title[0] = new MLabel(); //3
		title[1] = new MLabel(); //4
		Mat.addNode(title[0]);
		title[0].content = "it is title[0]";
		Mat.addNode(title[1]);
		title[1].content = "it is title[1]";
	
		MLabel intro = new MLabel();//5
		Mat.addNode(intro);
		MLabel[] testPoly = new MLabel[6];
		for(int i = 0; i<6; i++){
			testPoly[i] = new MLabel();// 6 - 11
		//	Mat.addNode(testPoly[i]);
		}
		MPic MPicAtTopRight = new MPic(); //12
		Mat.addNode(MPicAtTopRight);
		MPic MPicAtDownLeft = new MPic(); //13
		Mat.addNode(MPicAtDownLeft);
	//	MContainer titles = new MContainer();
	
	   	Mat.initMDoc(myMDoc);
	   	
		    ad.position_to = myMDoc;
		    ad.content = "The world's greatest collection of card magic!\nby genii";
		    ad.direction =  types.MDirection.INNERTOP;
		    ad.zaxis = 2;
	
		    MLabel[] titlesPath = new MLabel[2];
		    titlesPath[0] = new MLabel();//14
		    titlesPath[0].content = "title1.txt";
	//	    Mat.addNode(titlesPath[0]);
		    titlesPath[1] = new MLabel();//15
		    titlesPath[1].content = "title2.txt";
	//	    Mat.addNode(titlesPath[1]);
		    
		    for(int i = 0 ; i < 2; i++){
		    	title[i].position_to = myMDoc;
		    //	title[i].content = Mat.text(titlesPath[i].content);
		    	title[i].fontSize = myMDoc.fontSize * 2;
		    	title[i].zaxis = ad.zaxis;
		    }
	
		    title[0].direction = Mat.from( types.MDirection.down, 45);
		    System.out.println("from test:"+title[0].direction);
		    title[0].position_to = title[1];
		    title[0].distance = 100;
		    title[1].direction =  types.MDirection.INNERMIDDLE;	
		    MPicAtTopRight.position_to = myMDoc;
		    MPicAtTopRight.direction =  types.MDirection.INNERTOPRIGHT; //problem
		    MPicAtTopRight.path = "C:\\Temp\\pic.jpeg";
		    MPicAtTopRight.zaxis = ad.zaxis;
	
		    intro.position_to = title[1];
		//    intro.content = Mat.text("intro.txt");
		    intro.direction = Mat.from( types.MDirection.down, 0);
		    intro.distance = 2 * myMDoc.defaultdistance;
		    intro.zaxis = ad.zaxis;
	
		    MLabel content = new MLabel();//16
		    Mat.addNode(content);
		    content.position_to = MPicAtTopRight;
		    content.content = Mat.text("C:\\Temp\\test.txt");
		    content.direction = Mat.degree((MObject)title[0],(MObject)title[1]);
		    content.distance = 1*myMDoc.defaultdistance;
		    System.out.println("degree test:"+content.direction);
		    
		    MPic piccenter = new MPic();//16
		    Mat.addNode(piccenter);
		    piccenter.position_to = MPicAtTopRight;
		    piccenter.direction = 20;
		    piccenter.distance =50;
		    piccenter.path = "C:" + "\\Temp\\pic.jpeg";
		    piccenter.zaxis = ad.zaxis;
	
	/*	    piccenter.position_to = MPicAtTopRight;
		    piccenter.direction = Mat.from(types.MDirection.down, 0);
		    piccenter.distance = 10*myMDoc.defaultdistance;
		    */
		    System.out.println("degree test:"+piccenter.direction);
		    
		    int dis = 0;
		    for(int i = 0 ; i < 6; i++){
		for(int j = 0 ; j < i; j++){
		    if(j == 0)
		dis = dis + 1;
		    if(j == i-1)
		testPoly[i].fontSize = j + myMDoc.fontSize;
		}
		testPoly[i].zaxis = ad.zaxis - 1;
		    }
		    testPoly[0].content = "M";
		    testPoly[1].content = "A";
		    testPoly[2].content = "G";
		    testPoly[3].content = "I";
		    testPoly[4].content = "C";
		    testPoly[5].content = "!";
		    
		    for(int i=0; i<6; i++)
		    	Mat.addNode(testPoly[i]);
		    //titles = title[0];
		    //titles += title[1];
		    dis = dis * Mat.distance((MObject)ad, (MObject)intro);
		    System.out.println("distance test:"+dis);
		    Mat.poly(testPoly, 6, piccenter, 50, Mat.from( types.MDirection.right, 45));
	/*
		    MPicAtTopRight.position_to = myMDoc;
		    MPicAtTopRight.direction = types.MDirection.INNERDOWN;
		    MPicAtTopRight.path = "pic";
		    MPicAtTopRight.zaxis = ad.zaxis;
		*/	
	
//			Mat.process();
	//		Mat.calcCoordinate();
			Mat.printObjects();
		    Mat.layout1();
	}
}